<template>
	<view class="container">
		<uni-nav-bar class="ch-nav" height="96rpx" backgroundColor="#ffffff" leftWidth="90rpx" rightWidth="90rpx" color="#333" :fixed="true" :padding="false" :border="true" @clickLeft="$goBack(1)">
			<template slot="left">
				<image class="left" src="@/public/images/public/dhl_fhjt.png" mode="aspectFit"></image>
			</template>
			<text class="title">{{title}}</text>
			<template slot="right">
			</template>
		</uni-nav-bar>
		<web-view class="webview" :src="src" v-if="src != null"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: null,
				name: null
			}
		},
		computed: {
			title() {
				if(this.name == 'inform'){
					return '平台公告'
				}else{
					return '彩虹体育'
				}
			}
		},
		onLoad() {
			if(this.$Route.query.src){
				this.src = this.$Route.query.src
			}
			window.addEventListener('message', this.handlerFunction, false);
		},
		onUnload() {
			window.removeEventListener('message', this.handlerFunction, false);
		},
		methods: {
			handlerFunction(event) {
				console.log(event.data)
				if(event.data.title){
					this.name = event.data.title
				}
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #FFFFFF;
	}
	.container{
		padding: 0;
	}
	.webview{
		margin-top: 96rpx;
		margin-bottom: var(--safe-area-inset-bottom);
	}
	.ch-nav{
		.title{
			font-size: 34rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	}
</style>
